<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
	<title>修改支付密码</title>
	<link rel="stylesheet" href="../../css/aui.css" />
	<link rel="stylesheet" href="../../css/my/reset_password.css">
</head>
<body style="cursor: pointer;">
	<ul class="aui-list aui-form-list from_padded aui-padded-t-15" style="border:none;">
		<form id="myform" data-parsley-trigger="blur" role="form" action="#" method="POST">
			<li class="aui-list-item" id="old_pwd">
				<label style="width:50%;line-height:2.2rem;">原密码：</label>
				<input type="password" name="oldPassword" placeholder="请输入原密码(填写6位数字密码)">
			</li>
			<li class="aui-list-item ">
				<label style="width:50%;line-height:2.2rem;">新密码：</label>
				<input type="password" name="password" placeholder="请输入新密码(填写6位数字密码)">
			</li>
			<li class="aui-list-item col_center">
				<label style="width:50%;line-height:2.2rem;">确认新密码：</label>
				<input type="password" name="rePassword" placeholder="请输入确认密码(填写6位数字密码)">
			</li>
			<div class="aui-btn aui-btn-block btn_padded reset" onclick="pay_password_submit()">确定</div>
		</form>
	</ul>
</body>
</html>
<script type="text/javascript" src="../../script/aui/api.js"></script>
<script type="text/javascript" src="../../script/extend/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="../../script/aui/aui-toast.js" ></script>
<script type="text/javascript" src="../../script/config.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script type="text/javascript">
	apiready = function() {
		console.log(api.pageParam.isExists);
		if (api.pageParam.isExists == 0) {
			$('#old_pwd').hide();
		} else {
			$('#old_pwd').show();
		}

		api.parseTapmode();
	};

    // TODO: 修改密码
    function pay_password_submit(){
        oldPassword  = $('input[name=oldPassword]').val();
        password     = $('input[name=password]').val();
        rePassword   = $('input[name=rePassword]').val();

				if (api.pageParam.isExists != 0) {
						//验证旧密码
						if (!isDefine(oldPassword)) {
							$toast('请输入原始密码');
							return;
						}
				}

				if (!isDefine(password)) {
						$toast('请输入新密码');
						return;
				}

				if (!isDefine(rePassword)) {
					$toast('请再次输入新密码');
					return;
				}

				if(!checkPayPwd(password)){
					return;
				}

				if (!recheckpayPwd(password,rePassword)) {
					$toast('两次密码输入不一致');
					return;
				}

        var data = {oldPassword: oldPassword, password:password, rePassword:rePassword};
        ajax({url:Config.common.modifyPayPassword, data:data},function(ret){
            if (ret.code == 1) {
                alert('支付密码修改成功！');
								api.closeWin({});
            } else {
                alert(ret.msg);
            }
        })
    }
</script>
